package com.hex.ds.hdtp.core.app.script.transfer.dto.response;

import cn.hutool.core.io.FileUtil;
import com.hex.ds.hdtp.core.app.common.util.FileEncodeUtil;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.File;

/**
 * @Package com.hex.ds.hdtp.core.app.transfer.script.dto.response
 * @ClassName ScriptConvertListHisResponseDto
 * @Description 脚本转换清单历史-response对象
 * @Author Guo jiajun
 * @Date 2023/5/15 15:43
 * @Version v1.0
 **/
@Data
@Accessors(chain = true)
public class ScriptConvertOptLogResponseDto {

    private String pkId;

    private String scriptConvertListId;

    private String fileName;

    private String sourceFilePath;

    private String modifyFilePath;

    private String crtUser;

    private String crtUserName;

    private String crtTs;

    private String sourceFileContent;

    private String modifyFileContent;

    public String getSourceFileContent() {
        if (FileUtil.exist(sourceFilePath) && FileUtil.isFile(sourceFilePath)){
            return FileUtil.readString(sourceFilePath, FileEncodeUtil.getFileEncode(sourceFilePath));
        }
        return sourceFileContent;
    }

    public String getModifyFileContent() {
        if (FileUtil.exist(modifyFilePath) && FileUtil.isFile(modifyFilePath)){
            return FileUtil.readString(modifyFilePath, FileEncodeUtil.getFileEncode(modifyFilePath));
        }
        return modifyFileContent;
    }
}
